package com.ghxxzx.dagl.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ghxxzx.dagl.entity.Dajy;
import com.ghxxzx.dagl.entity.Dalx;
import com.ghxxzx.dagl.entity.Daxx;
import com.ghxxzx.dagl.entity.User;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;
@Repository
public interface DalxMapper extends BaseMapper<Dalx> {
    @Select("SELECT * FROM dalx")
    List<Dalx> finAll();

    @Select("SELECT * from dalx WHERE parent_id !=(SELECT id FROM dalx WHERE dalx_name='文书档案') AND parent_id!=0")
    List<Dalx> findAllfirst();
    @Select("SELECT * from dalx WHERE parent_id!=0")
    List<Dalx> findAllfirstWs();
    @Select("SELECT * FROM dalx where parent_id != 0 and (dalx_name='文书档案' OR parent_id =(SELECT id FROM dalx WHERE dalx_name='文书档案'))")
    Dalx findByWs();
    @Select("SELECT * FROM dalx where parent_id = #{id}")
    List<Dalx> findParentIdEq(@Param("id") Integer dalx);

    @Select("SELECT * FROM dalx where parent_id != 0 and dalx_name!='文书档案' and parent_id !=(SELECT id FROM dalx WHERE dalx_name='文书档案')")
    List<Dalx> selectListNoRoot();
    @Select("SELECT * FROM dalx where parent_id != 0 and (dalx_name='文书档案' OR parent_id =(SELECT id FROM dalx WHERE dalx_name='文书档案'))")
    List<Dalx> selectListNoRootWs();


    @Select("SELECT * FROM dalx where parent_id != 0")
    List<Dalx> selectListNoRootandWs();
    @Select("SELECT id FROM dalx where id = #{id} and dalx_name=#{name}")
    Integer findByIdAndName(@Param("id") Integer wdlx, @Param("name") String name);
    @Select("SELECT id FROM `dalx` WHERE `code`=#{code}")
    Integer findByCode(@Param("code") String code);
}
